<?php

function eve_api_settings_form($form_state) {
	$form = array();

	if ($edit['cert_id']) {
		// -- rank id only needed if we are editing a rank.
    	$form['cert_id'] = array('#type' => 'hidden', '#value' => $edit['cert_id']);
  	}
  
	// -- pictures path
	$form['pictures_path'] = array (
		'#type' => 'textfield',
		'#title' => t('Pictures Path'),
		'#size' => 64,
		'#maxlength' => 256,
		'#description' => t('Path to put pictures downloaded from the Eve API.'),
		'#default_value' => variable_get('eve_api_pictures_path', ''),
	);
	
	return $form;
}

function eve_api_settings_form_validate($form, &$form_state)  {
	$values = $form_state['values'];
	if ($values['pictures_path'] != check_file($values['pictures_path'])) {
		form_set_error('name', "The pictures path must be a valid subpath of drupal.");
	}
}

function eve_api_settings_form_submit($form, &$form_state)  {
	$values = $form_state['values'];
	if (isset($values['pictures_path'])) {
		variable_set('eve_api_pictures_path', $values['pictures_path']);
	}
	return drupal_goto('admin/settings/eve_api');
}

function eve_api_settings() {
	return drupal_get_form('eve_api_settings_form');
}
